﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace timetableasy.Models
{
    public class StudentUserRepository : UserRepository
    {
        private TimeTableDBDataContext db = new TimeTableDBDataContext();

        //Query Methods
        public IQueryable<StudentUser> FindAllStudentUsers()
        {
            return db.StudentUsers;
        }

        public StudentUser GetStudentUserById(int id)
        {
            return db.StudentUsers.SingleOrDefault(su => su.UserIdFK == id);
        }

        //Insert/Delete Methods

        public void Add(StudentUser StudentUser)
        {
            db.StudentUsers.InsertOnSubmit(StudentUser);
        }

        public void Delete(StudentUser StudentUser)
        {
            db.StudentUsers.DeleteOnSubmit(StudentUser);
        }

        //Persistence

        public void Save()
        {
            db.SubmitChanges();
        }
    }
}